/***************************************************************************
 创建者：       hualei
 开始时间：    2018.09.10
 copyright:(C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************/
#include "musicinstructiondelegate.h"
#include "../../FtpManage/ftpmanage.h"
#include <QDebug>
#include "../../CommunicateDelegate/filedata.h"
#include "../../CommunicateDelegate/globaldata.h"

extern FtpManage *ftpManage;
extern FileData fileData;

MusicInstructionDelegate::MusicInstructionDelegate(GlobalData *globalDataIn, QWidget *parent)
    : QWidget(parent)
{
    globalData=globalDataIn;
}

void MusicInstructionDelegate::initView()
{
    musicInstructionView->instructionOut = "";
    musicInstructionView->musicFileName = "";
    musicInstructionView->musicPlayTimes = 1;
    musicInstructionView->musicVolume = 100;
    musicInstructionView->noteStr = "";

    if(globalData->isUseFtpOrNfs)
    {
        fileData.ftpOperateNum = EM_FTP_OPERATE_MUSIC;
        ftpManage->getFileInDirectory(CONTROL_MUSICFILE_PATH, CONTROL_MUSICFILE_PATH);
    }
<<<<<<< HEAD
=======
}

int MusicInstructionDelegate::setMusicFileList(QVector<QString> musicFileListIn)
{
    return musicInstructionView->setMusicFileList(musicFileListIn);
}

int MusicInstructionDelegate::setMusicFileList_std(std::vector<std::string> musicFileListIn)
{
    QVector<QString> musicFileListQt;
    for(int i=0;i<musicFileListIn.size();i++)
    {
        musicFileListQt.append(QString::fromStdString(musicFileListIn[i]));
    }
    return musicInstructionView->setMusicFileList(musicFileListQt);
>>>>>>> dev
}

void MusicInstructionDelegate::finishedEditInstructionSlot()
{
    musicInstructionView->instructionOut = tr("MUSIC ");
    musicInstructionView->instructionOut += musicInstructionView->musicFileName + ",";
    if(musicInstructionView->musicPlayTimes == -1)
    {
        musicInstructionView->instructionOut += tr("循环,");
    }
    else if(musicInstructionView->musicPlayTimes == 0)
    {
        musicInstructionView->instructionOut += tr("暂停,");
    }
    else
    {
        musicInstructionView->instructionOut += QString::number(musicInstructionView->musicPlayTimes) + ",";
    }
    musicInstructionView->instructionOut += QString::number(musicInstructionView->musicVolume);
    musicInstructionView->instructionOut += tr("    //") + musicInstructionView->noteStr;

    qDebug() << "Finished Edit Instruction :" << musicInstructionView->instructionOut;
}

void MusicInstructionDelegate::cleanNoteSlot()
{
    musicInstructionView->noteStr.clear();
}
